class Solution {
   public:
    int numRabbits(vector<int>& answers) {
        unordered_map<int, int> map1;
        for (int& n : answers) {
            map1[n]++;
        }
        int ans = 0;
        for (auto& iter : map1) {
            int y = iter.first;
            int x = iter.second;
            if (x % (y + 1) == 0)
                ans += x;
            else
                ans += ((x / (y + 1)) + 1) * (y + 1);
        }
        return ans;
    }
};